set more 1

/*
File:	cepr_org_family.do
Date:	Feb 20, 2006
		Mar 21, 2011 CEPR ORG Version 1.6.1
		Mar 12, 2015, CEPR ORG Version 2.0
		Apr  1, 2015, CEPR ORG Version 2.0.1
		March 1, 2016, CEPR ORG Version 2.1
		Oct 12, 2016, CEPR ORG Version 2.1.1
		Feb 9, 2017, CEPR ORG Version 2.2
		Apr 21, 2017, CEPR ORG Version 2.2.1
		Apr 10, 2018, CEPR ORG Version 2.3
		Mar 22, 2019, CEPR ORG Version 2.4
		Jul 24, 2019, CEPR ORG Version 2.4.1
	    Feb 05, 2020, CEPR ORG Version 2.5
	
Desc:	Creates consistent family-relationship variables for CEPR consistent
	extract	of CPS ORG
Note:	See copyright notice at end of program.
*/

/* Determine data year */
local year=year in 1
if `year'==-17345 {local year  = 1980}
di "`year'"

/* Marital status */

gen byte married=0 if marital~=.
replace married=1 if 1<=marital & marital<=3
lab var married "Married"
notes married: CPS: derived from a-maritl, prmarsta

gen marstat=.

/* Number of own children under age 18 in primary family;
   uses NBER's ownchild variable */

if 1979<=`year' & `year'<=1983 {
gen byte ownchild=.
}
if 1984<=`year' & `year'<=1993 {
/* recode non-reference person, non-spouse to missing
for consistency */
replace ownchild=. if (pfamrel~=1 & pfamrel~=2 & pfamrel ~=5)
}

lab var ownchild "Number of children"
notes ownchild: Number of own children under 18 in primary family
notes ownchild: Not available in CPS for years 1994 to 1999:10
notes ownchild: Available 1984-93 and 2000- only
notes ownchild: CPS: derived by NBER from a-pfnocd, prnmchld

/* Presence of own child, by child's age */

if (1979<=`year' & `year'<=1983) {
gen byte ch05=.
gen byte ch613=.
gen byte ch1417=.
}
if (1979<=`year' & `year'<=1988) {
gen byte ch02=.
gen byte ch35=.
}
if 1984<=`year' & `year'<=1993 {
/* recode non-reference person, non-spouse to missing
for consistency */
replace ch02=. if (pfamrel~=1 & pfamrel~=2 & pfamrel ~=5)
replace ch05=. if (pfamrel~=1 & pfamrel~=2 & pfamrel ~=5)
replace ch35=. if (pfamrel~=1 & pfamrel~=2 & pfamrel ~=5)
replace ch613=. if (pfamrel~=1 & pfamrel~=2 & pfamrel ~=5)
replace ch1417=. if (pfamrel~=1 & pfamrel~=2 & pfamrel ~=5)
}

lab var ch02 "Child 0-2"
notes ch02: Available 1989-93 and 2000- only
notes ch02: CPS: derived by NBER from a-pfprcd, prchld
lab var ch05 "Child 0-5"
notes ch05: Available 1984-93 and 2000- only
notes ch05: CPS: derived by NBER from a-pfprcd, prchld
lab var ch35 "Child 3-5"
notes ch35: Available 1989-93 and 2000- only
notes ch35: CPS: derived by NBER from a-pfprcd, prchld
lab var ch613 "Child 6-13"
notes ch613: Available 1984-93 and 2000- only
notes ch613: CPS: derived by NBER from a-pfprcd, prchld
lab var ch1417 "Child 14-17"
notes ch1417: Available 1984-93 and 2000- only
notes ch1417: CPS: derived by NBER from a-pfprcd, prchld

/* Family relationship */

if 1979<=`year' & `year'<=1983 {
gen byte famrel84=.
gen byte famrel94=.
gen byte famrel=.
}
if 1984<=`year' & `year'<=1993 {
gen byte famrel94=.
gen byte famrel=1 if 1<=pfamrel & pfamrel<=2
replace famrel=2 if pfamrel==3
replace famrel=3 if pfamrel==4
replace famrel=1 if pfamrel==5
replace famrel=4 if pfamrel==0
*
gen byte famrel84=pfamrel
replace famrel84=6 if pfamrel==0
}

lab var famrel84 "Family relation"
#delimit ;
lab def fr84
1 "Husband"
2 "Wife"
3 "Own child"
4 "Other relative"
5 "Unmarried reference person"
6 "Not in primary family"
;
#delimit cr
lab val famrel84 fr84
notes famrel84: Not available 1979-83 or 1994-
notes famrel84: CPS: a-pfamrel

lab var famrel94 "Family relation"
#delimit ;
lab def fr94
1 "Reference person"
2 "Spouse"
3 "Own child"
4 "Other relative"
5 "Not in primary family"
;
#delimit cr
/* 5 "Unmarried reference person" 
is listed in the NBER documentation for 1994-, but no observations
have a value==5 and the original CPS documentation from 1994 list only
the five categories in label fr94
*/
lab val famrel94 fr94
notes famrel94: Not available 1979-83
notes famrel94: CPS: prfamrel

lab var famrel "Family relation"
#delimit ;
lab def fr
1 "Head, spouse, or unmarried reference person"
2 "Own child"
3 "Other relative"
4 "Not in primary family"
;
#delimit cr
lab val famrel fr
notes famrel: Not available 1979-83
notes famrel: CPS: a-pfamrel, prfamrel

/* Head of Household */

if 1989<=`year' & `year'<=1993 {
gen byte relahh=.
}

gen hoh79=0
if 1979<=`year' & `year'<=1983 {
replace hoh79=1 if (1<=relahh & relahh<=3)
}
if 1984<=`year' & `year'<=1993 {
replace hoh79=1 if famrel==1
}

notes hoh79: CPS: prfamrel a-pfamrel relah

/* Reference person */

gen byte refper=.

/* Family income, by income bands 

"(COMBINED INCOME OF ALL FAMILY MEMBERS
DURING THE LAST 12 MONTHS. INCLUDES
MONEY FROM JOBS, NET INCOME FROM
BUSINESS, FARM OR RENT, PENSIONS,
DIVIDENDS, INTEREST, SOCIAL SECURITY
PAYMENTS AND ANY OTHER MONEY INCOME
RECEIVED BY FAMILY MEMBERS WHO ARE 15
YEARS OF AGE OR OLDER.)"

Census Note:Caution should be used when using this variable since it 
				has an allocation rate of approximately 20 percent.
*/

gen byte faminc=.

/* 
Copyright 2020 CEPR and John Schmitt

This file is part of the cepr_org_master.do program. This file and all
programs referenced in it are free software. You can redistribute the
program or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
USA.
*/

